package top.juntower.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.juntower.pojo.*;
import top.juntower.service.impl.FirstPageInformationServiceImpl;
import top.juntower.utils.JsonResult;

import java.util.List;

@Api(tags = "首页")
@RestController
@RequestMapping("firstpage")
public class FirstPageInformationController {

    @Autowired
    FirstPageInformationServiceImpl firstPageInformationService;

    //首页轮播图
    @ApiOperation(value = "首页轮播图",response = GameTypeInformation.class)
    @GetMapping("/firstPageLun")
    public JsonResult firstPageLun() {
        List<FirstPageInformation> firstPageInformations = firstPageInformationService.firstPageLun();
        if (firstPageInformations == null){
            return JsonResult.error(JsonResult.MISS);
        }
        return  JsonResult.ok(firstPageInformations);
    }

    //首页精品推荐
    @ApiOperation(value = "首页精品推荐",response = GameTypeInformation.class)
    @GetMapping("/firstPageJing")
    public JsonResult firstPageJing() {
        List<FirstPageInformationNew> firstPageInformationNews = firstPageInformationService.firstPageJing();
        if (firstPageInformationNews == null){
            return JsonResult.error(JsonResult.MISS);
        }
        return  JsonResult.ok(firstPageInformationNews);
    }

    //首页最热新游
    @ApiOperation(value = "首页最热新游",response = GameTypeInformation.class)
    @GetMapping("/firstPageHot")
    public JsonResult firstPageHot() {
        List<FirstPageInformationHot> firstPageInformationHots = firstPageInformationService.firstPageHot();
        if (firstPageInformationHots == null){
            return JsonResult.error(JsonResult.MISS);
        }
        return  JsonResult.ok(firstPageInformationHots);
    }

    //首页热度榜
    @ApiOperation(value = "首页热度榜",response = GameTypeInformation.class)
    @GetMapping("/firstPageHotRanking")
    public JsonResult firstPageHotRanking() {
        List<FirstPageInformationHot> firstPageInformationHots = firstPageInformationService.firstPageHotRanking();
        if (firstPageInformationHots == null){
            return JsonResult.error(JsonResult.MISS);
        }
        return  JsonResult.ok(firstPageInformationHots);
    }
}
